import React, { useRef, forwardRef, useImperativeHandle } from 'react';
import { Form, Input } from 'antd';

const { Item: FormItem } = Form;

export default forwardRef((_, ref) => {
  const formRef = useRef(null);
  useImperativeHandle(ref, () => ({
    setFormValue,
    getFieldsValue,
  }));
  async function setFormValue(val) {
    await formRef.current.setFieldsValue(val);
  }
  function getFieldsValue() {
    return formRef.current.getFieldsValue();
  }
  return (
    <Form ref={formRef}>
      <FormItem label="节点名称" name="title">
        <Input />
      </FormItem>
    </Form>
  );
});
